<template>
  <div>
    <a-card :bordered='false'>
      <f-search-form :more='true' @searchHandler='searchHandler'
                     @exportHandler='exportHandler'
                     :show-export-btn='true' 
                     :exportUrl='api.hyOrderDetails.exportTemplate'>
        <f-search-form-item label='部门' ref='dept' name='deptId' type='select' :data='api.hyorder.deptList' valueKey='deptId' label-key='deptName' />
        <f-search-form-item label='订单编号' name='orderNo' />
        <f-search-form-item label='发货日期' type='range' name='beginDate' />
      </f-search-form>
      <f-table ref='table' rowKey='orderDetailsId' 
               :showSetting='true' :tableColumns='columns'
               :scroll='{x:true}' :multiple='false'
               :operator='operator'
               :params='queryParam' :api='api.hyOrderDetails.page' handler='hyOrderDetailsReportHandler'>
        <span slot='outOrderNo' slot-scope='text, record, index'>
            <span v-clipboard:copy='text' v-clipboard:success='onCopy' style='cursor:pointer'>{{ text }}</span>
        </span>
        <span slot='customName' slot-scope='text, record, index'>
          <f-elipsis :text='text' :length='30'></f-elipsis>
        </span>
        <span slot='sendType' slot-scope='text, record, index'>
           <a-tag color='#2db7f5' v-if='text==1'>现款</a-tag>
            <a-tag color='#FF0000' v-if='text==2'>预收款</a-tag>
            <a-tag color='#87d068' v-if='text==3'>资保金</a-tag>
            <a-tag color='purple' v-if='text==4'>全额资信</a-tag>
        </span>
        <span slot='orderType' slot-scope='text, record, index'>
           <a-tag color='#2db7f5' v-if='text=="CHA"'>销售</a-tag>
            <a-tag color='#FF0000' v-if='text=="CKC"'>报损</a-tag>
            <a-tag color='#87d068' v-if='text=="CKD"'>盘损</a-tag>
            <a-tag color='purple' v-if='text=="CKE"'>赠品</a-tag>
            <a-tag color='purple' v-if='text=="CKF"'>移出</a-tag>
            <a-tag color='purple' v-if='text=="CKG"'>其他</a-tag>
            <a-tag color='purple' v-if='text=="CKI"'>退补</a-tag>
            <a-tag color='purple' v-if='text=="CKJ"'>退货</a-tag>
            <a-tag color='purple' v-if='text=="CKL"'>领用</a-tag>
        </span>
        <span slot='drugType' slot-scope='text, record, index'>
           <a-tag color='#2db7f5' v-if='text=="ZY"'>自营</a-tag>
            <a-tag color='#FF0000' v-if='text=="ZS"'>招商</a-tag>
        </span>
      </f-table>
    </a-card>

  </div>
</template>
<script>
import api from "./../../js/api"

export default {
  name: "HyMingXiList",
  components: {},
  data() {
    let me = this
    //操作按钮
    let operator = []
    let isCw = this.$store.state.user.roleInfo.isCw
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {
        companyId: this.$store.state.user.companyId,
        fileName:"业务明细表"
      },
      tableObj: null,
      superAdmin: this.superAdmin,
      // 表头
      columns: [
        {
          title: "序号",
          width: "70px",
          align: "center",
          fixed: "left",
          customRender: (text, record, index) => index + 1
        },

        {
          title: "单据日期",
          align: "left",
          width: "90px",
          fixed: "left",
          dataIndex: "sendDate"
        },
        {
          title: "单据编码",
          align: "center",
          fixed: "left",
          dataIndex: "outOrderNo",
          scopedSlots: { customRender: "outOrderNo" }
        },
        {
          title: "单据类型",
          align: "left",
          sorter: true,
          width: "100px",
          dataIndex: "orderType",
          scopedSlots: { customRender: "orderType" }
        },
        {
          title: "单位名称",
          align: "left",
          width: "180px",
          ellipsis: true,
          dataIndex: "customName",
          scopedSlots: { customRender: "customName" }
        },
        {
          title: "业务员",
          align: "left",
          width: "80px",
          dataIndex: "saleManName"
        },
        {
          title: "业务编码",
          align: "left",
          width: "90px",
          dataIndex: "businessCode"
        },
        {
          title: "部门",
          align: "left",
          width: "90px",
          ellipsis: true,
          dataIndex: "deptName"
        },
        {
          title: "区域",
          align: "left",
          sorter: true,
          width: "80px",
          dataIndex: "businessArea"
        },
        {
          title: "发货方式",
          align: "left",
          sorter: true,
          width: "100px",
          dataIndex: "sendType",
          scopedSlots: { customRender: "sendType" }
        },
        {
          title: "商品类型",
          align: "left",
          sorter: true,
          width: "100px",
          dataIndex: "drugType",
          scopedSlots: { customRender: "drugType" }
        },
        {
          title: "商品名称",
          align: "left",
          width: "75px",
          sorter: true,
          dataIndex: "drugsName"
        },
        {
          title: "生产厂家",
          align: "left",
          width: "120px",
          ellipsis: true,
          sorter: true,
          dataIndex: "producersName"
        },
        {
          title: "件容",
          align: "left",
          sorter: true,
          width: "60px",
          ellipsis: true,
          dataIndex: "drugJr"
        },
        {
          title: "批号",
          align: "left",
          sorter: true,
          width: "80px",
          ellipsis: true,
          dataIndex: "drugLotNo"
        },
        {
          title: "含税单价",
          align: "left",
          width: "70px",
          ellipsis: true,
          dataIndex: "salePrice"
        },
        {
          title: "数量",
          align: "left",
          width: "70px",
          dataIndex: "saleNum"
        },
        {
          title: "发货金额",
          align: "left",
          width: "70px",
          dataIndex: "saleAmount"
        },
        {
          title: "成本单价",
          align: "left",
          width: "90px",
          hidden: !isCw,
          dataIndex: "costPrice"
        },
        {
          title: "成本金额",
          align: "left",
          width: "80px",
          hidden: !isCw,
          dataIndex: "costAmount"
        },
        
 /*       {
          title: "渠道商",
          align: "center",
          width: "100px",
          children: [
            {
              title: "结算价",
              align: "left",
              width: "100px",
              dataIndex: "settlePrice"
            },
            {
              title: "结算标准",
              align: "left",
              width: "100px",
              dataIndex: "settleRate"
            },
            {
              title: "结算金额",
              align: "left",
              width: "100px",
              dataIndex: "settleAmount"
            },
            {
              title: "发货结算金额",
              align: "left",
              width: "100px",
              dataIndex: "settleSendAmount"
            },
            {
              title: "结算高开税金",
              align: "left",
              width: "100px",
              dataIndex: "settleSendAmount"
            },
            {
              title: "发票金额",
              align: "left",
              width: "100px",
              dataIndex: "invoiceAmount"
            },
            {
              title: "付款日期",
              align: "left",
              width: "100px",
              dataIndex: "invoicePayDate"
            }
          ]
        },

        {
          title: "商务经理",
          align: "center",
          width: "100px",
          children: [
            {
              title: "结算价",
              align: "left",
              width: "100px",
              dataIndex: "settlePriceD"
            },
            {
              title: "结算标准",
              align: "left",
              width: "100px",
              dataIndex: "settleRateD"
            },
            {
              title: "结算金额",
              align: "left",
              width: "100px",
              dataIndex: "settleAmountD"
            },
            {
              title: "发票金额",
              align: "left",
              width: "100px",
              dataIndex: "invoiceAmountD"
            },
            {
              title: "付款日期",
              align: "left",
              width: "100px",
              dataIndex: "invoicePayDateD"
            }
          ]
        },
        
        {
          title: "片区服务商",
          align: "center",
          width: "100px",
          children: [
            {
              title: "结算价",
              align: "left",
              width: "100px",
              dataIndex: "settlePriceC"
            },
            {
              title: "结算标准",
              align: "left",
              width: "100px",
              dataIndex: "settleRateC"
            },
            {
              title: "结算金额",
              align: "left",
              width: "100px",
              dataIndex: "settleAmountC"
            },
            {
              title: "发票金额",
              align: "left",
              width: "100px",
              dataIndex: "invoiceAmountC"
            },
            {
              title: "付款日期",
              align: "left",
              width: "100px",
              dataIndex: "invoicePayDateC"
            }
          ]
        },
        
        
        {
          title: "商务总负责人",
          align: "center",
          width: "100px",
          children: [
            {
              title: "结算价",
              align: "left",
              width: "100px",
              dataIndex: "settlePriceE"
            },
            {
              title: "结算标准",
              align: "left",
              width: "100px",
              dataIndex: "settleRateE"
            },
            {
              title: "结算金额",
              align: "left",
              width: "100px",
              dataIndex: "settleAmountE"
            },
            {
              title: "发票金额",
              align: "left",
              width: "100px",
              dataIndex: "invoiceAmountE"
            },
            {
              title: "付款日期",
              align: "left",
              width: "100px",
              dataIndex: "invoicePayDateE"
            }
          ]
        },
        {
          title: "资保金",
          align: "center",
          width: "100px",
          children: [
            {
              title: "应收金额",
              align: "left",
              width: "100px",
              dataIndex: "customBondAmount"
            }, {
              title: "收款金额",
              align: "left",
              width: "100px",
              dataIndex: "customBondTakeAmount"
            }, {
              title: "收款日期",
              align: "left",
              width: "100px",
              dataIndex: "customBondDate"
            }, {
              title: "收款银行",
              align: "left",
              width: "100px",
              dataIndex: "customBondBankName"
            }, {
              title: "退款金额",
              align: "left",
              width: "100px",
              dataIndex: "customBondRetAmount"
            },
            {
              title: "退款日期",
              align: "left",
              width: "100px",
              dataIndex: "customBondRetDate"
            },
            {
              title: "退款银行",
              align: "left",
              width: "100px",
              dataIndex: "customBondRetBankName"
            }
          ]
        },

        {
          title: "利润",
          align: "center",
          width: "100px",
          hidden: !isCw,
          children: [
            {
              title: "公司利润",
              align: "center",
              width: "100px",
              hidden: !isCw,
              dataIndex: "profitAmount"
            }, {
              title: "税收利润",
              align: "center",
              width: "100px",
              hidden: !isCw,
              dataIndex: "taxProfitAmount"
            }, {
              title: "产品利润",
              align: "center",
              width: "100px",
              hidden: !isCw,
              dataIndex: "drugProfitAmount"
            }, {
              title: "边际利润",
              align: "center",
              width: "100px",
              hidden: !isCw,
              dataIndex: "bjProfitAmount"
            }, {
              title: "支付开票税金",
              align: "center",
              width: "100px",
              hidden: !isCw,
              dataIndex: "payInvoiceTaxAmount"
            }, {
              title: "管理利润",
              align: "center",
              sorter: true,
              width: "100px",
              hidden: !isCw,
              dataIndex: "manageProfitAmount"
            }
          ]
        }*/
      ],
      operator: operator
    }
  },
  created() {
  },
  mounted() {
    this.tableObj = this.$refs.table
  },
  methods: {
    onCopy() {
      this.$message.success("复制成功!")
    },
    initSettle(record) {
      // this.http.confirm(this, {
      //   content: '确认初始化结算吗?',
      //   url: api.payment.initSettlePayment,
      //   data: {
      //     orderDetailsId: record.orderDetailsId
      //   }
      // })
    },
    clearExport() {
      this.http.post(this, {
        url: this.api.hyOrderDetails.clearExportData
      })
    }
  }
}
</script>
